#include "dtgenre.h"

DtGenre::DtGenre()
{
}

DtGenre::DtGenre(const QString &name, const int id)
{
    this->id = id;
    this->name = name;
}

DtGenre::DtGenre(const DtGenre &genre)
{
    this->id = genre.id;
    this->name = genre.name;
}

DtGenre::~DtGenre()
{

}

QDebug operator<<(QDebug dbg, const DtGenre &genre)
{
    dbg.space() << "Genre" << genre.getId() << genre.getName();
    return dbg.space();
}

void DtGenre::clicked(const int section)
{
    switch (section) {
    case 0: /* Play */
        playSvg.setPlay(!playSvg.isPlay());
        break;
    case 1: /* Ajouter */
        break;
    case 2: /* Titre du track*/
        break;
    case 3: /* Heart */
        heart.setHeart(!heart.isHeart());
        DbGenre::setHeart(*this);
        break;
    default:
        break;
    }
}

DtGenre * DtGenre::findById(QList<DtGenre> & sGenre, const int id)
{
    for(QList<DtGenre>::Iterator it = sGenre.begin();
        it != sGenre.end(); it++)
    {
        if((*it).getId() == id)
            return &(*it);
    }
    return NULL;
}

void DtGenre::addTrack(DtTrack *track)
{
    if(!lTrack.contains(track))
        lTrack.append(track);
}

void DtGenre::addAlbum(DtAlbum *album)
{
    if(!lAlbum.contains(album))
        lAlbum.append(album);
}

void DtGenre::addArtist(DtArtist *Artist)
{
    if(!lArtist.contains(Artist))
        lArtist.append(Artist);
}

QList<DtAlbum *> &DtGenre::getAlbums()
{
    return lAlbum;
}

QList<DtTrack *> &DtGenre::getTracks()
{
    return lTrack;
}

QList<DtArtist *> &DtGenre::getArtists()
{
    return lArtist;
}
